import React, { FC } from "react"
import { Outlet } from "react-router-dom"
import useLoadUserData from "../../hooks/useLoadUserData"
import { Spin } from "antd"
import useNavPage from "../../hooks/useNavPage"
const QuestionLayout: FC = () => {
    // 加载用户信息
    const { waitingUserData } = useLoadUserData()
    // 用户没有登录时，跳转到登录页
    useNavPage(waitingUserData)
    return (
        <div style={{ height: "100vh" }}>
            {/* 路由占位符 */}
            {/* 不用等待加载用户数据（等待完成），渲染页面 */}
            {waitingUserData ? (
                <div style={{ textAlign: "center", marginTop: "60px" }}>
                    <Spin />
                </div>
            ) : (
                <Outlet />
            )}
        </div>
    )
}

export default QuestionLayout
